using SDK.Scripts.Utils;
using UnityEngine;

namespace SDK.Scripts.Plat
{
	public class GamePlatAndroid : BaseGamePlat
	{
		private static AndroidJavaObject _jo;

		private AndroidJavaObject jo => GetJavaObject();

		private static AndroidJavaObject GetJavaObject()
		{
			if (_jo == null)
			{
				AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
				_jo = androidJavaClass.GetStatic<AndroidJavaObject>("currentActivity");
			}
			return _jo;
		}

		public override void Login(bool isGuest)
		{
			Common.SafeCall(delegate
			{
				jo.Call("login", base.ListingName, "OnCallBack", 0L);
			});
		}

		public override void SwitchAccount()
		{
			Common.SafeCall(delegate
			{
				jo.Call("switchAccount", base.ListingName, "OnCallBack", 1L);
			});
		}

		public override void Pay(string payInfo)
		{
			Common.SafeCall(delegate
			{
				jo.Call("pay", base.ListingName, "OnCallBack", payInfo, 2L);
			});
		}

		public override string DoAction(platActionID id, string str = "")
		{
			string actionResult = string.Empty;
			Common.SafeCall(delegate
			{
				actionResult = jo.Call<string>("action", new object[5]
				{
					base.ListingName,
					"OnCallBack",
					(int)id,
					str,
					3L
				});
			});
			return actionResult;
		}
	}
}
